package com.example.zk2_lx.db;

import android.app.Application;

import androidx.room.Room;

public class AppDBUtils {
    private AppDBUtils(){}
    private static AppDBUtils appDBUtils = new AppDBUtils();
    public static AppDBUtils getInstance(){
        return appDBUtils;
    }

    private AppDataBase appDataBase;
    private MessageDao messageDao;
    public void init(Application application){
        appDataBase = Room.databaseBuilder(application,AppDataBase.class,"2203a.db")
                .allowMainThreadQueries()
                .build();
        messageDao = appDataBase.getMessageDao();
    }

    public MessageDao getMessageDao(){
        if(messageDao==null){
            messageDao = appDataBase.getMessageDao();
        }
        return messageDao;
    }

}
